package com.example.springbootfileupload.controller;

import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;

/**
 * @ClassName FileUploadController
 * @Description FileUploadController 文件上传
 * @Author ZX
 * @Date 2020/5/26 12:55
 */
@RestController
public class FileUploadController {

    /**
     * @Description: 文件上传 MultipartFile file名字必须==html中file的name一致
     * @Param:
     * @return:
     */
    @PostMapping("/fileUploadController")
    public String fileUpload(MultipartFile file)throws Exception{
        System.out.println(file.getOriginalFilename());
        file.transferTo(new File("f:/"+file.getOriginalFilename()));
        return "OK";
    }

}
